package tomoto.util;

import java.util.BitSet;

/**
 * Helper utility for {@link java.util.BitSet}.
 * 
 * @author Tomoto Shimizu Washio
 * 
 */
public class BitSetUtil {
	@Deprecated
	private BitSetUtil() {}

	/**
	 * Returns a new BitSet by shifting the specified BitSet.
	 * 
	 * @param bs BitSet to shift.
	 * @param n number of bits to shift. Positive means left and negative means
	 *            right.
	 * @return new bit set
	 */
	public static BitSet shift(BitSet bs, int n) {
		BitSet result = new BitSet(bs.size());
		int max = Math.min(bs.size(), bs.size() - n);
		for (int i = Math.max(0, -n); i < max; i++) {
			result.set(i + n, bs.get(i));
		}
		return result;
	}
}
